

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
    <style>
    /* base */
    html,
    body,
    .container {
      width: 100%;
      height: 100%;
    }

    a,
    a:link,
    a:visited {
      text-decoration: none;
      color: inherit;
    }

    ul {
      list-style: none;
    }

    *,
    ::before,
    ::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    *:focus {
      outline: 0;
    }

    .container {
      display: flex;
      padding-top: 20px;
    }

    /* Nav */
    .container .doc-nav {
      position: fixed;
      height: 100%;
      margin: 0 30px 0 40px;
      width: 280px;
    }

    .doc-nav .nav-header {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      background-color: rgb(240, 241, 242);
      height: 40px;
      padding: 16px;
      font-size: 18px;
      font-weight: 500;
      color: rgb(62, 64, 66);
      cursor: pointer;
    }

    .doc-nav .nav-content {
      height: calc(100% - 40px);
      overflow-y: auto;
      color: rgb(32, 34, 36);
    }

    .doc-nav .nav-content .nav-list,
    .doc-nav .nav-content .nav-sub-list {
      line-height: 1.5rem;
    }

    .doc-nav .nav-content .nav-label {
      display: inline-block;
      position: relative;
      padding: 2px 0 2px 20px;
      margin-bottom: 4px;
    }

    .doc-nav .nav-content .nav-sub-label {
      position: relative;
      padding: 2px 0 2px 40px;
      font-size: 14px;
    }

    .doc-nav .nav-content .nav-sub-label:hover {
      text-decoration: underline;
    }

    .doc-nav .nav-content .nav-list .nav-label.group::before {
      border-bottom: 0.25rem solid transparent;
      border-left: 0.25rem solid #6e7072;
      border-right: 0;
      border-top: 0.25rem solid transparent;
      content: '';
      display: block;
      height: 0;
      left: 0.5rem;
      position: absolute;
      top: 0.625rem;
      transition: transform 0.1s linear;
      width: 0;
    }

    .doc-nav .nav-content .nav-list .nav-label.group.active::before {
      transform: rotate(90deg);
    }

    /* doc content */
    .container .doc-content {
      position: fixed;
      height: 100%;
      width: calc(100% - 80px - 40px - 30px - 240px);
      right: 0%;
      overflow-y: auto;
    }

    .doc-title {
      border-bottom: 1px solid #dcdee0;
      font-size: 22px;
      margin: 8px 0 0;
      padding-bottom: 16px;
    }

    .doc-content h3 {
      font-size: 24px;
      font-weight: 600;
      margin: 24px 0;
    }

    .doc-content h4 {
      font-size: 22px;
      font-weight: 500;
      margin: 30px 0 8px;
    }

    .doc-content h4 span {
      color: #007d9c;
    }

    .doc-content .doc-declare {
      background-color: #fafafa;
      border-radius: 5px;
      border: 1px solid #ccc;
      font-size: 14px;
      overflow-x: auto;
      padding: 10px;
      tab-size: 4;
      line-height: 20px;
    }

    .doc-content .doc-comment {
      font-size: 16px;
      margin: 16px 0;
      line-height: 24px;
      word-break: break-word;
    }
  </style>

</head>
<body>
  <div class="container">
    <div class="doc-nav">
      <a href="#Documentation" class="nav-header">Documentation</a>
      <nav class="nav-content">
        <ul class="nav-list">
          <li>
            <a href="#includes" class="nav-label">Includes</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#stdint.h" class="nav-sub-label">stdint.h</a>
              </li>
      

              <li>
                <a href="#stdbool.h" class="nav-sub-label">stdbool.h</a>
              </li>
      

              <li>
                <a href="#errno.h" class="nav-sub-label">errno.h</a>
              </li>
      

              <li>
                <a href="#tuya_os_adapter.h" class="nav-sub-label">tuya_os_adapter.h</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#macros" class="nav-label">Macros</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#__TUYA_HAL_NETWORK_H__" class="nav-sub-label">__TUYA_HAL_NETWORK_H__</a>
              </li>
      

              <li>
                <a href="#UNW_FD_SET(n,p)" class="nav-sub-label">UNW_FD_SET(n,p)</a>
              </li>
      

              <li>
                <a href="#UNW_FD_CLR(n, p)" class="nav-sub-label">UNW_FD_CLR(n, p)</a>
              </li>
      

              <li>
                <a href="#UNW_FD_ISSET(n,p)" class="nav-sub-label">UNW_FD_ISSET(n,p)</a>
              </li>
      

              <li>
                <a href="#UNW_FD_ZERO(p)" class="nav-sub-label">UNW_FD_ZERO(p)</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#functions" class="nav-label">Functions</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#tuya_hal_net_get_errno" class="nav-sub-label">tuya_hal_net_get_errno</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_fd_set" class="nav-sub-label">tuya_hal_net_fd_set</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_fd_clear" class="nav-sub-label">tuya_hal_net_fd_clear</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_fd_isset" class="nav-sub-label">tuya_hal_net_fd_isset</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_fd_zero" class="nav-sub-label">tuya_hal_net_fd_zero</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_select" class="nav-sub-label">tuya_hal_net_select</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_get_nonblock" class="nav-sub-label">tuya_hal_net_get_nonblock</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_set_block" class="nav-sub-label">tuya_hal_net_set_block</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_close" class="nav-sub-label">tuya_hal_net_close</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_shutdown" class="nav-sub-label">tuya_hal_net_shutdown</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_socket_create" class="nav-sub-label">tuya_hal_net_socket_create</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_connect" class="nav-sub-label">tuya_hal_net_connect</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_connect_raw" class="nav-sub-label">tuya_hal_net_connect_raw</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_bind" class="nav-sub-label">tuya_hal_net_bind</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_listen" class="nav-sub-label">tuya_hal_net_listen</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_send" class="nav-sub-label">tuya_hal_net_send</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_send_to" class="nav-sub-label">tuya_hal_net_send_to</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_recv" class="nav-sub-label">tuya_hal_net_recv</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_recvfrom" class="nav-sub-label">tuya_hal_net_recvfrom</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_set_timeout" class="nav-sub-label">tuya_hal_net_set_timeout</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_set_bufsize" class="nav-sub-label">tuya_hal_net_set_bufsize</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_set_reuse" class="nav-sub-label">tuya_hal_net_set_reuse</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_disable_nagle" class="nav-sub-label">tuya_hal_net_disable_nagle</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_set_boardcast" class="nav-sub-label">tuya_hal_net_set_boardcast</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_set_keepalive" class="nav-sub-label">tuya_hal_net_set_keepalive</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_gethostbyname" class="nav-sub-label">tuya_hal_net_gethostbyname</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_accept" class="nav-sub-label">tuya_hal_net_accept</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_recv_nd_size" class="nav-sub-label">tuya_hal_net_recv_nd_size</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_str2addr" class="nav-sub-label">tuya_hal_net_str2addr</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_socket_bind" class="nav-sub-label">tuya_hal_net_socket_bind</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_set_cloexec" class="nav-sub-label">tuya_hal_net_set_cloexec</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_get_socket_ip" class="nav-sub-label">tuya_hal_net_get_socket_ip</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_addr" class="nav-sub-label">tuya_hal_net_addr</a>
              </li>
      

              <li>
                <a href="#tuya_hal_net_setsockopt" class="nav-sub-label">tuya_hal_net_setsockopt</a>
              </li>
      

              <li>
                <a href="#tuya_os_network_intf_init" class="nav-sub-label">tuya_os_network_intf_init</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#vars" class="nav-label">Vars</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#char" class="nav-sub-label">char</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#consts" class="nav-label">Consts</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#types" class="nav-label">Types</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#typedefs" class="nav-label">Typedefs</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
        </ul>
      </nav>
    </div>
    <div class="doc-content">
      <h2 id="Documentation" class="doc-title">Documentation</h2>
      <h3 id="includes">Includes</h3>
      

      <h4 id="stdint.h"><span>stdint.h</span></h4>
      <pre class="doc-declare"><code>#include &lt;stdint.h&gt;
</code></pre>
      <pre class="doc-comment">#include <stdint.h>
</pre>

      <h4 id="stdbool.h"><span>stdbool.h</span></h4>
      <pre class="doc-declare"><code>#include &lt;stdbool.h&gt;
</code></pre>
      <pre class="doc-comment">#include <stdbool.h>
</pre>

      <h4 id="errno.h"><span>errno.h</span></h4>
      <pre class="doc-declare"><code>#include &lt;errno.h&gt;
</code></pre>
      <pre class="doc-comment">#include <errno.h>
</pre>

      <h4 id="tuya_os_adapter.h"><span>tuya_os_adapter.h</span></h4>
      <pre class="doc-declare"><code>#include "tuya_os_adapter.h"
</code></pre>
      <pre class="doc-comment">#include "tuya_os_adapter.h"
</pre>
      <h3 id="macros">Macros</h3>
      

      <h4 id="__TUYA_HAL_NETWORK_H__">Marco <span>__TUYA_HAL_NETWORK_H__</span></h4>
      <pre class="doc-declare"><code>#define __TUYA_HAL_NETWORK_H__
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="UNW_FD_SET(n,p)">Marco <span>UNW_FD_SET(n,p)</span></h4>
      <pre class="doc-declare"><code>#define UNW_FD_SET(n,p)    tuya_hal_net_fd_set(n, p)
</code></pre>
      <pre class="doc-comment">//Add file descriptor to set</pre>

      <h4 id="UNW_FD_CLR(n, p)">Marco <span>UNW_FD_CLR(n, p)</span></h4>
      <pre class="doc-declare"><code>#define UNW_FD_CLR(n, p)   tuya_hal_net_fd_clear(n, p)
</code></pre>
      <pre class="doc-comment">//Clear file descriptor from set</pre>

      <h4 id="UNW_FD_ISSET(n,p)">Marco <span>UNW_FD_ISSET(n,p)</span></h4>
      <pre class="doc-declare"><code>#define UNW_FD_ISSET(n,p)  tuya_hal_net_fd_isset(n,p)
</code></pre>
      <pre class="doc-comment">//Check file descriptor is in set</pre>

      <h4 id="UNW_FD_ZERO(p)">Marco <span>UNW_FD_ZERO(p)</span></h4>
      <pre class="doc-declare"><code>#define UNW_FD_ZERO(p)     tuya_hal_net_fd_zero(p)
</code></pre>
      <pre class="doc-comment">//Clear all descriptor in set</pre>
      <h3 id="functions">Functions</h3>
      

      <h4 id="tuya_hal_net_get_errno">Func <span>tuya_hal_net_get_errno</span></h4>
      <pre class="doc-declare"><code>UNW_ERRNO_T tuya_hal_net_get_errno(void);</code></pre>
      <pre class="doc-comment">/**
* @brief Get error code of network
*
* @param void
*
* @note This API is used for getting error code of network.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_fd_set">Func <span>tuya_hal_net_fd_set</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_fd_set(int fd, UNW_FD_SET_T* fds);</code></pre>
      <pre class="doc-comment">/**
* @brief Add file descriptor to set
*
* @param[in] fd: file descriptor
* @param[in] fds: set of file descriptor
*
* @note This API is used to add file descriptor to set.
*
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_fd_clear">Func <span>tuya_hal_net_fd_clear</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_fd_clear(int fd, UNW_FD_SET_T* fds);</code></pre>
      <pre class="doc-comment">/**
* @brief Clear file descriptor from set
*
* @param[in] fd: file descriptor
* @param[in] fds: set of file descriptor
*
* @note This API is used to clear file descriptor from set.
*
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_fd_isset">Func <span>tuya_hal_net_fd_isset</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_fd_isset(int fd, UNW_FD_SET_T* fds);</code></pre>
      <pre class="doc-comment">/**
* @brief Check file descriptor is in set
*
* @param[in] fd: file descriptor
* @param[in] fds: set of file descriptor
*
* @note This API is used to check the file descriptor is in set.
*
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_fd_zero">Func <span>tuya_hal_net_fd_zero</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_fd_zero(UNW_FD_SET_T* fds);</code></pre>
      <pre class="doc-comment">/**
* @brief Clear all file descriptor in set
*
* @param[in] fds: set of file descriptor
*
* @note This API is used to clear all file descriptor in set.
*
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_select">Func <span>tuya_hal_net_select</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_select(const int maxfd, UNW_FD_SET_T *readfds, UNW_FD_SET_T *writefds,
                               UNW_FD_SET_T *errorfds, const UINT_T ms_timeout);</code></pre>
      <pre class="doc-comment">/**
* @brief Get available file descriptors
*
* @param[in] maxfd: max count of file descriptor
* @param[out] readfds: a set of readalbe file descriptor
* @param[out] writefds: a set of writable file descriptor
* @param[out] errorfds: a set of except file descriptor
* @param[in] ms_timeout: time out
*
* @note This API is used to get available file descriptors.
*
* @return the count of available file descriptors.
*/</pre>

      <h4 id="tuya_hal_net_get_nonblock">Func <span>tuya_hal_net_get_nonblock</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_get_nonblock(const int fd);</code></pre>
      <pre class="doc-comment">/**
* @brief Get no block file descriptors
*
* @param[in] fd: file descriptor
*
* @note This API is used to get no block file descriptors.
*
* @return the count of no block file descriptors.
*/</pre>

      <h4 id="tuya_hal_net_set_block">Func <span>tuya_hal_net_set_block</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_set_block(const int fd, const bool block);</code></pre>
      <pre class="doc-comment">/**
* @brief Set block flag for file descriptors
*
* @param[in] fd: file descriptor
* @param[in] block: block flag
*
* @note This API is used to set block flag for file descriptors.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_close">Func <span>tuya_hal_net_close</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_close(const int fd);</code></pre>
      <pre class="doc-comment">/**
* @brief Close file descriptors
*
* @param[in] fd: file descriptor
*
* @note This API is used to close file descriptors.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_shutdown">Func <span>tuya_hal_net_shutdown</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_shutdown(const int fd, const int how);</code></pre>
      <pre class="doc-comment">/**
* @brief Shutdown file descriptors
*
* @param[in] fd: file descriptor
* @param[in] how: shutdown type
*
* @note This API is used to shutdown file descriptors.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_socket_create">Func <span>tuya_hal_net_socket_create</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_socket_create(const UNW_PROTOCOL_TYPE type);</code></pre>
      <pre class="doc-comment">/**
* @brief Create a tcp/udp socket
*
* @param[in] type: protocol type, tcp or udp
*
* @note This API is used for creating a tcp/udp socket.
*
* @return file descriptor
*/</pre>

      <h4 id="tuya_hal_net_connect">Func <span>tuya_hal_net_connect</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_connect(const int fd, const UNW_IP_ADDR_T addr, const UINT16_T port);</code></pre>
      <pre class="doc-comment">/**
* @brief Connect to network
*
* @param[in] fd: file descriptor
* @param[in] addr: address information of server
* @param[in] port: port information of server
*
* @note This API is used for connecting to network.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_connect_raw">Func <span>tuya_hal_net_connect_raw</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_connect_raw(const int fd, void *p_socket, const int len);</code></pre>
      <pre class="doc-comment">/**
* @brief Connect to network with raw data
*
* @param[in] fd: file descriptor
* @param[in] p_socket: raw socket data
* @param[in] len: data lenth
*
* @note This API is used for connecting to network with raw data.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_bind">Func <span>tuya_hal_net_bind</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_bind(const int fd, const UNW_IP_ADDR_T addr, const UINT16_T port);</code></pre>
      <pre class="doc-comment">/**
* @brief Bind to network
*
* @param[in] fd: file descriptor
* @param[in] addr: address information of server
* @param[in] port: port information of server
*
* @note This API is used for binding to network.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_listen">Func <span>tuya_hal_net_listen</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_listen(const int fd, const int backlog);</code></pre>
      <pre class="doc-comment">/**
* @brief Listen to network
*
* @param[in] fd: file descriptor
* @param[in] backlog: max count of backlog connection
*
* @note This API is used for listening to network.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_send">Func <span>tuya_hal_net_send</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_send(const int fd, const void *buf, const UINT_T nbytes);</code></pre>
      <pre class="doc-comment">/**
* @brief Send data to network
*
* @param[in] fd: file descriptor
* @param[in] buf: send data buffer
* @param[in] nbytes: buffer lenth
*
* @note This API is used for sending data to network
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_send_to">Func <span>tuya_hal_net_send_to</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_send_to(const int fd, const void *buf, const UINT_T nbytes,
                                const UNW_IP_ADDR_T addr, const UINT16_T port);</code></pre>
      <pre class="doc-comment">/**
* @brief Send data to specified server
*
* @param[in] fd: file descriptor
* @param[in] buf: send data buffer
* @param[in] nbytes: buffer lenth
* @param[in] addr: address information of server
* @param[in] port: port information of server
*
* @note This API is used for sending data to network
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_recv">Func <span>tuya_hal_net_recv</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_recv(const int fd, void *buf, const UINT_T nbytes);</code></pre>
      <pre class="doc-comment">/**
* @brief Receive data from network
*
* @param[in] fd: file descriptor
* @param[in] buf: receive data buffer
* @param[in] nbytes: buffer lenth
*
* @note This API is used for receiving data from network
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_recvfrom">Func <span>tuya_hal_net_recvfrom</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_recvfrom(const int fd, void *buf, const UINT_T nbytes,
                                  UNW_IP_ADDR_T *addr, UINT16_T *port);</code></pre>
      <pre class="doc-comment">/**
* @brief Receive data from specified server
*
* @param[in] fd: file descriptor
* @param[in] buf: receive data buffer
* @param[in] nbytes: buffer lenth
* @param[in] addr: address information of server
* @param[in] port: port information of server
*
* @note This API is used for receiving data from specified server
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_set_timeout">Func <span>tuya_hal_net_set_timeout</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_set_timeout(const int fd, const int ms_timeout, const UNW_TRANS_TYPE_E type);</code></pre>
      <pre class="doc-comment">/**
* @brief Set timeout option of socket fd
*
* @param[in] fd: file descriptor
* @param[in] ms_timeout: timeout in ms
* @param[in] type: transfer type, receive or send
*
* @note This API is used for setting timeout option of socket fd.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_set_bufsize">Func <span>tuya_hal_net_set_bufsize</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_set_bufsize(const int fd, const int buf_size, const UNW_TRANS_TYPE_E type);</code></pre>
      <pre class="doc-comment">/**
* @brief Set buffer_size option of socket fd
*
* @param[in] fd: file descriptor
* @param[in] buf_size: buffer size in byte
* @param[in] type: transfer type, receive or send
*
* @note This API is used for setting buffer_size option of socket fd.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_set_reuse">Func <span>tuya_hal_net_set_reuse</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_set_reuse(const int fd);</code></pre>
      <pre class="doc-comment">/**
* @brief Enable reuse option of socket fd
*
* @param[in] fd: file descriptor
*
* @note This API is used to enable reuse option of socket fd.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_disable_nagle">Func <span>tuya_hal_net_disable_nagle</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_disable_nagle(const int fd);</code></pre>
      <pre class="doc-comment">/**
* @brief Disable nagle option of socket fd
*
* @param[in] fd: file descriptor
*
* @note This API is used to disable nagle option of socket fd.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_set_boardcast">Func <span>tuya_hal_net_set_boardcast</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_set_boardcast(const int fd);</code></pre>
      <pre class="doc-comment">/**
* @brief Enable broadcast option of socket fd
*
* @param[in] fd: file descriptor
*
* @note This API is used to enable broadcast option of socket fd.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_set_keepalive">Func <span>tuya_hal_net_set_keepalive</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_set_keepalive(int fd, const bool alive, const UINT_T idle, const UINT_T intr, const UINT_T cnt);</code></pre>
      <pre class="doc-comment">/**
* @brief Set keepalive option of socket fd to monitor the connection
*
* @param[in] fd: file descriptor
* @param[in] alive: keepalive option, enable or disable option
* @param[in] idle: keep idle option, if the connection has no data exchange with the idle time(in seconds), start probe.
* @param[in] intr: keep interval option, the probe time interval.
* @param[in] cnt: keep count option, probe count.
*
* @note This API is used to set keepalive option of socket fd to monitor the connection.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_gethostbyname">Func <span>tuya_hal_net_gethostbyname</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_gethostbyname(const char *domain, UNW_IP_ADDR_T *addr);</code></pre>
      <pre class="doc-comment">/**
* @brief Get address information by domain
*
* @param[in] domain: domain information
* @param[in] addr: address information
*
* @note This API is used for getting address information by domain.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_accept">Func <span>tuya_hal_net_accept</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_accept(const int fd, UNW_IP_ADDR_T *addr, UINT16_T *port);</code></pre>
      <pre class="doc-comment">/**
* @brief Accept the coming socket connection of the server fd
*
* @param[in] fd: file descriptor
* @param[in] addr: address information of server
* @param[in] port: port information of server
*
* @note This API is used for accepting the coming socket connection of the server fd.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_recv_nd_size">Func <span>tuya_hal_net_recv_nd_size</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_recv_nd_size(const int fd, void *buf, const UINT_T buf_size, const UINT_T nd_size);</code></pre>
      <pre class="doc-comment">/**
* @brief Receive data from network with need size
*
* @param[in] fd: file descriptor
* @param[in] buf: receive data buffer
* @param[in] nbytes: buffer lenth
* @param[in] nd_size: the need size
*
* @note This API is used for receiving data from network with need size
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_str2addr">Func <span>tuya_hal_net_str2addr</span></h4>
      <pre class="doc-declare"><code>UNW_IP_ADDR_T tuya_hal_net_str2addr(const char *ip_str);</code></pre>
      <pre class="doc-comment">/**
* @brief Change ip string to address
*
* @param[in] ip_str: ip string
*
* @note This API is used to change ip string to address.
*
* @return ip address
*/</pre>

      <h4 id="tuya_hal_net_socket_bind">Func <span>tuya_hal_net_socket_bind</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_socket_bind(int fd, const char *ip);</code></pre>
      <pre class="doc-comment">/**
* @brief Bind to network with specified ip
*
* @param[in] fd: file descriptor
* @param[in] ip: ip address
*
* @note This API is used for binding to network with specified ip.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_set_cloexec">Func <span>tuya_hal_net_set_cloexec</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_set_cloexec(const int fd);</code></pre>
      <pre class="doc-comment">/**
* @brief Set socket fd close mode
*
* @param[in] fd: file descriptor
*
* @note This API is used for setting socket fd close mode, the socket fd will not be closed in child processes generated by fork calls.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_get_socket_ip">Func <span>tuya_hal_net_get_socket_ip</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_get_socket_ip(int fd, UNW_IP_ADDR_T *addr);</code></pre>
      <pre class="doc-comment">/**
* @brief Get ip address by socket fd
*
* @param[in] fd: file descriptor
* @param[out] addr: ip address
*
* @note This API is used for getting ip address by socket fd.
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_hal_net_addr">Func <span>tuya_hal_net_addr</span></h4>
      <pre class="doc-declare"><code>UNW_IP_ADDR_T tuya_hal_net_addr(const char *ip);</code></pre>
      <pre class="doc-comment">/**
* @brief Get ip address by ip string
*
* @param[in] ip: ip string
*
* @note This API is used for getting ip address by ip string
*
* @return ip address
*/</pre>

      <h4 id="tuya_hal_net_setsockopt">Func <span>tuya_hal_net_setsockopt</span></h4>
      <pre class="doc-declare"><code>int tuya_hal_net_setsockopt(int fd, int level, int optname, void *optval, int optlen);</code></pre>
      <pre class="doc-comment">/**
* @brief set sock option
*
* @param[in] fd: socket id
* @param[in] level: level
* @param[in] optname: optname
* @param[in] optval: optval
* @param[in] optlen: optlen
*
* @note This API is used for set sock option
*
* @return UNW_SUCCESS on success. Others on error, please refer to tuya_os_adapter_error_code.h
*/</pre>

      <h4 id="tuya_os_network_intf_init">Func <span>tuya_os_network_intf_init</span></h4>
      <pre class="doc-declare"><code>VOID_T tuya_os_network_intf_init(VOID_T);</code></pre>
      <pre class="doc-comment">/**
 * @brief Network interface initialization
 *
 * @param VOID
 *
 * @note This API is used for initialization of network interface.
 *
 * @return VOID
 */</pre>
      <h3 id="vars">Vars</h3>
      

      <h4 id="char">Variable <span>char</span></h4>
      <pre class="doc-declare"><code>char* tuya_hal_net_addr2str(UNW_IP_ADDR_T ipaddr);</code></pre>
      <pre class="doc-comment">/**
* @brief Change ip address to string
*
* @param[in] ipaddr: ip address
*
* @note This API is used to change ip address(in host byte order) to string(in IPv4 numbers-and-dots(xx.xx.xx.xx) notion).
*
* @return ip string
*/</pre>
      <h3 id="consts">Consts</h3>
      
      <h3 id="types">Types</h3>
      
      <h3 id="typedefs">Typedefs</h3>
      
    </div>
  </body>
</html>
            